using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using Utils.Tool.ReadFile;

public class AutoStartUp : MonoBehaviour
{
    private string packName = "";
    private string filePath = "";
    // Start is called before the first frame update
    void Start()
    {
        packName = string.Format("com.{0}.{1}",Application.companyName,Application.productName);
#if UNITY_EDITOR
        filePath = string.Format("{0}/appcfg.txt", "d:/");
#else
        filePath = string.Format("/{0}/appcfg.txt", "sdcard");
#endif
        if (!File.Exists(filePath))
        {
            //创建一个新文件，向其中写入内容，然后关闭文件。 如果目标文件已存在，则会将其截断并覆盖。
            File.WriteAllText(filePath, packName);
        }

#if UNITY_ANDROID
        var apkfile = string.Format("{0}/{1}{2}.apk", "sdcard", Application.productName, ConfigFileOperation.ReadConfig("VersionInfo", "0.0.1").Replace(".", ""));
        var updatefile = string.Format("{0}/update.txt", "sdcard");
        if (File.Exists(updatefile))
        {
            File.Delete(updatefile);
        }
        if (File.Exists(apkfile))
        {
            File.Delete(apkfile);
        }
#endif
    }

}
